package com.atguigu.cloud.service.impl;

import com.atguigu.cloud.entities.Pay;
import com.atguigu.cloud.mapper.PayMapper;
import com.atguigu.cloud.service.PayService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author HanYiMing
 * @description
 * @date 2024/3/19
 * @lastEditDate 2024/3/19
 * @lastEditAuthor
 * @lastDescription
 */
@Service
public class PayServiceImpl implements PayService {

    @Resource
    private PayMapper payMapper;

    /**
     * @param pay 订单信息
     * @return 返回添加结果
     * @description 添加订单信息
     * @author HanYiMing
     * @date 2024/3/19
     */
    @Override
    public int add(Pay pay) {
        return payMapper.insertSelective(pay);
    }

    /**
     * @param id 订单id
     * @return 删除结果
     * @description 根据id删除订单信息
     * @author HanYiMing
     * @date 2024/3/19
     */
    @Override
    public int delete(Integer id) {
        return payMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(Pay pay) {
        return payMapper.updateByPrimaryKeySelective(pay);
    }

    @Override
    public Pay getById(Integer id) {
        return payMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Pay> getAll() {
        return payMapper.selectAll();
    }
}
